package com.qf.service.impl;



import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.entity.User;
import com.qf.service.UserService;

import java.sql.SQLException;

/**
 * @Author peng
 * @Date 2023/8/21 13:10
 * @Version 1.0.0
 */

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
//登入
    @Override
    public User loginUser(String username, String password) {
        try {
            return userDao.loginUser(username,password);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

//    注册
    @Override
    public int addUser(String uname, String password, String sex,String address,String phone) {
        try {
            return   userDao.addUser(uname,password,sex,phone,address);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public User selectUserById(Integer uid) {
        try {
            return userDao.selectUserById(uid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int deleteUid(int uid) {
        try {
            return userDao.deleteUid(uid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int updateUser(User user) {

        try {
            return userDao.updateUser(user);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
